$(function(){
	var obj=document.getElementsByName('taobaoke_usename'); 
	var a='';  
	for(var i=0; i<obj.length; i++){ 
		if(obj[i].checked) a+='<button type="button" class="btn btn-success btn-xs" style="margin-bottom: 5px;margin-right: 5px;">'+obj[i].value+'</button>'; 
	} 
	document.getElementById('taobaoke_use').innerHTML = a;
});

function UrlSearch() 
{
   var name,value; 
   var str=location.href; //取得整个地址栏
   var num=str.indexOf("?") 
   str=str.substr(num+1); //取得所有参数   stringvar.substr(start [, length ]

   var arr=str.split("&"); //各个参数放到数组里
   for(var i=0;i < arr.length;i++){ 
    num=arr[i].indexOf("="); 
    if(num>0){ 
     name=arr[i].substring(0,num);
     value=arr[i].substr(num+1);
     this[name]=value;
     } 
    } 
}
function taobaoke_uselist() 
{
	var obj=document.getElementsByName('taobaoke_usename'); 
	var a='';  
	for(var i=0; i<obj.length; i++){ 
		if(obj[i].checked) a+='<button type="button" class="btn btn-success btn-xs" style="margin-bottom: 5px;margin-right: 5px;">'+obj[i].value+'</button>'; 
	} 
	document.getElementById('taobaoke_use').innerHTML = a;
}
function checkAll(name) { 
	var el = document.getElementsByTagName('input'); 
	var len = el.length; 
	for(var i=0; i<len; i++) { 
		if((el[i].type=="checkbox") && (el[i].name==name)) { 
		el[i].checked = true; 
		} 
	} 
	var obj=document.getElementsByName('taobaoke_usename'); 
	var a='';  
	for(var i=0; i<obj.length; i++){ 
		if(obj[i].checked) a+='<button type="button" class="btn btn-success btn-xs" style="margin-bottom: 5px;margin-right: 5px;">'+obj[i].value+'</button>'; 
	} 
	document.getElementById('taobaoke_use').innerHTML = a;
} 
function clearAll(name) { 
	var el = document.getElementsByTagName('input'); 
	var len = el.length; 
	for(var i=0; i<len; i++) { 
		if((el[i].type=="checkbox") && (el[i].name==name)) { 
		el[i].checked = false; 
		} 
	} 
	document.getElementById('taobaoke_use').innerHTML = '';
} 
function taobaoke_use_do() 
{
	var Request=new UrlSearch();
	var taobaoke_id=Request.taobaoke_id;
	var obj=document.getElementsByName('taobaoke_usename'); 
	var a=''; 
	for(var i=0; i<obj.length; i++){ 
	if(obj[i].checked) a+=obj[i].value+','; 
	} 
	toastr.options = {
			  "closeButton": true,
			  "debug": false,
			  "progressBar": true,
			  "positionClass": "toast-bottom-full-width",
			  "onclick": null,
			  "showDuration": "400",
			  "hideDuration": "1000",
			  "timeOut": "7000",
			  "extendedTimeOut": "1000",
			  "showEasing": "swing",
			  "hideEasing": "linear",
			  "showMethod": "fadeIn",
			  "hideMethod": "fadeOut"
			}
	var taobaoke_use = $.ajax({
               type: "POST",
               url: "plus.php?m=taobaoke&c=taobaoke_home&a=taobaoke_use_do",
               data: "taobaoke_id="+taobaoke_id+"&taobaoke_use="+a,
               async: false
            }).responseText;
			if (taobaoke_use == "1"){
				toastr.info("编辑失败！");
				self.location.reload();
			} else if (taobaoke_use == "2") {
				toastr.success("编辑成功！");
				self.location.reload();
			} else {
				toastr.error("请勿提交非法数据！");
				self.location.reload();
			}
}
